package com.clubs.coding.utils;

import com.clubs.coding.common.Constant;

import org.apache.tomcat.util.codec.binary.Base64;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/*
* MD5工具封装*/
public class MD5Utils {
    public static String getMD5Str(String Strvalue) throws NoSuchAlgorithmException {
        MessageDigest md5 =  MessageDigest.getInstance("MD5");//拿到加密工具
        return Base64.encodeBase64URLSafeString(md5.digest((Strvalue+ Constant.SALT).getBytes() ));//使用base64对返回的密文转码
    }

    public static void main(String[] args) throws NoSuchAlgorithmException {
       String STR =  getMD5Str("12345678");
        System.out.println(STR);
    }
}
